#pragma once

#include "Common/ComTypeDefine.h"
#include "Common/DuplicateDefine.h"

class IDuplicate;
struct IBlock 
{
	//初始化
	virtual bool intit(uint32_t blockId,uint32_t dupId,uint32_t sceneId) = 0;
	//
	virtual void uninit() = 0;
	//改变阻挡状态
	virtual bool changeState() = 0;
	//阻挡状态
	virtual int8_t blockState() = 0;
};

struct BlockBlockCfgInfo;
class Block : public IBlock
{
	enum
	{
		EBlock_InitState_Close = 0,	//初始关闭状态
		EBlock_InitState_Open = 1,	//初始开启状态
		EBlock_Change_Infinite = 0,	//触发无限次
	};
public:
	//初始化
	virtual bool intit(uint32_t blockId, uint32_t dupId, uint32_t sceneId);
	//
	virtual void uninit();
	//改变阻挡状态
	virtual bool changeState();
	//阻挡状态
	virtual int8_t blockState() { return m_byState; };
public:
	Block();
	~Block();
private:
	uint32_t m_blockId;
	int8_t m_byState;
	int32_t m_changeCount;
	const BlockBlockCfgInfo *m_pBlockCfg;
	uint32_t m_dupId;
	uint32_t m_sceneId;
};


class DupBlock
{
	typedef unordered_map<uint32_t,IBlock*> BlockMap;
public:
	bool Init(IDuplicate *pDuplicate);
	//
	void UnInit();
	//玩家进入区域
	void OnEnterArea(uint32_t areaId);
	//怪物死亡
	void OnMonsDie(uint32_t monsId, int32_t count, uint32_t formationId);
	//使用物件
	void OnUseThing(uint32_t thingId);
	//怪物出生
	void OnMonsBorn(uint32_t monsId,uint32_t formationId);
	//获取阻挡状态
	void GetAllBlockState(MAP_UINT32_INT8 &mapBlockState);
public:
	DupBlock();
	~DupBlock();
private:
	IBlock *GetBlock(uint32_t blockId);
	void NotifyBlockState(MAP_UINT32_INT8 &mapBlockState);
private:
	AllBlockDataCfg *m_pBlockCfg;
	BlockMap m_mapBlock;
	IDuplicate *m_pDuplicate;
};